Inner Joins

So far we have only been selecting data from a single table. But we can also get data from multiple tables at once.

Use the JOIN clause to do this.

It works by joining tables together based on a related column between them. The joining columns usually have similar names and the data must be the same type.

The rows in the joined table will contain the columns that you have specified in your SELECT statement from both tables where the join condition is met.

Here is an example:

SELECT table1.column1, table2.column2...
FROM table1
INNER JOIN table2 ON table1.matching_column = table2.matching_column;

`table1` and `table2` are the tables to be joined

`table1.column1, table2.column2...` are the columns that you want to select. When using a join, you must specify which table the columns come from, because the tables might have columns with the same name and postgresql wouldn't know which table you mean

`table1.matching_column = table2.matching_column` is the INNER JOIN condition. It specifies what columns to base the join on